package com.hxt.xt.service.z.rule;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.BooleanUtils;
import org.assertj.core.util.Lists;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;

import com.google.common.collect.Maps;
import com.hxt.xt.service.base.BaseMgr;

@Component("com.hxt.xt.service.z.rule.StorageRule")
public class StorageRule extends BaseMgr {

	/**
	 */
	public List<Map<String, Object>> sto10000() throws Exception {
//		hos.setCreate_time(DateUtil.getToday());
//
//		rule.tTohsDao.saveObject(hos);
		List<Map<String, Object>> list = rule.iMyBatisDao.query("CommonCustomMapper.selectOne", null);
		if (BooleanUtils.negate(ObjectUtils.isEmpty(list))) {
			for (Map<String, Object> m : list) {
				Map<String, Object> p = Maps.newHashMap();
				String code = m.get("code").toString();
				p.put("pcode", code);
				List<Map<String, Object>> list2 = rule.iMyBatisDao.query("CommonCustomMapper.selectTwo", p);
				m.put("opt", list2);

				if (BooleanUtils.negate(ObjectUtils.isEmpty(list2))) {
					for (Map<String, Object> m2 : list2) {
						Map<String, Object> p2 = Maps.newHashMap();
						// 当type=3时是填空
						if ("3".equals(m2.get("type").toString())) {
							m2.put("opt", Lists.newArrayList());
						} else {
							String code2 = m2.get("code").toString();
							p2.put("pcode", code2);
							List<Map<String, Object>> list3 = rule.iMyBatisDao.query("CommonCustomMapper.selectThree",
									p2);
							m2.put("opt", list3);
						}

					}

				}
			}

		}
		return list;
	}

	

}
